package com.wj.controller;


import com.wj.service.NacosClientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/nacos-client")
public class NacosClientController {

     private final NacosClientService nacosClientService;

     public NacosClientController(NacosClientService nacosClientService){
         this.nacosClientService = nacosClientService;
     }

    /**
     * 根据 serviceId 获取服务所有实例信息
     *
     * @param serviceId
     * @return
     */
     @GetMapping("/service-instance")
     public List<ServiceInstance> logNacosClientInfo(@RequestParam(defaultValue = "wj-code-nacos-client") String serviceId){
         log.info("coming in log nacos client info: [{}]",serviceId);
         return nacosClientService.getNacosClientInfo(serviceId);

     }
}
